import { defineStore } from 'pinia';

export const useNotificationStore = defineStore('notification', {
  state: () => ({
    notifications: [],
    nextId: 0,
  }),
  actions: {
    add(notification) {
      const id = this.nextId++;
      this.notifications.push({
        ...notification,
        id,
        visible: true,
      });
      return id; // [修正] 只返回 ID
    },
    remove(id) {
      const index = this.notifications.findIndex((n) => n.id === id);
      if (index !== -1) {
        this.notifications.splice(index, 1);
      }
    },
  },
}); 